const useTime = (time: Date) => {
  const y = time.getFullYear()
  let mm = time.getMonth() + 1
  let d = time.getDate()
  let h = time.getHours()
  let m = time.getMinutes()
  let s = time.getSeconds()
  let dateStr = y + '-'
  if (mm < 10) {
    dateStr += '0' + mm
  } else {
    dateStr += mm
  }
  dateStr += '-'
  if (d < 10) {
    dateStr += '0' + d
  } else {
    dateStr += d
  }
  dateStr += ' '
  if (h < 10) {
    dateStr += '0' + h
  } else {
    dateStr += h
  }
  dateStr += ':'
  if (m < 10) {
    dateStr += '0' + m
  } else {
    dateStr += m
  }
  dateStr += ':'
  if (s < 10) {
    dateStr += '0' + s
  } else {
    dateStr += s
  }
  return dateStr
}
const getTime = () => {
  return useTime(new Date())
}
export { useTime, getTime }
